package com.hashwolf.newpipe.error

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.hashwolf.newpipe.R

class ErrorUtil {
    companion object {
        private const val TAG = "ErrorUtil";

        private const val ERROR_REPORT_NOTIFICATION_ID = 5340681

        @JvmStatic
        fun openActivity(context: Context, errorInfo: ErrorInfo) {
//            context.startActivity(getErrorActivityIntent)
            Log.e(TAG, "openActivity: 错误信息");
        }

//        private fun getErrorActivityIntent(context: Context, errorInfo: ErrorInfo): Intent {
////            val intent = Intent(context, ErrorActivity)
//        }

        @JvmStatic
        fun showSnackbar(context: Context, errorInfo: ErrorInfo) {
//            val rootView = (context as? Activity)?.findViewById<View>(android.R.id.content);
//            showSnackbar()
        }

        @JvmStatic
        fun createNotification(context: Context, errorInfo: ErrorInfo) {
//            val notificationBuilder: NotificationCompat.Builder =
//                NotificationCompat.Builder(
//                    context,
//                    context.getString(R.string.error_report_channel_id)
//                ).setSmallIcon(R.drawable.ic_bug_report)
//                    .setContentTitle(context.getString(R.string.error_report_notification_title))
//                    .setContentText(context.getString(errorInfo.messageStringId))
//                    .setAutoCancel(true)
//            // TODO: 后续补充点击查看错误详情
//            NotificationManagerCompat.from(context).notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder);
//            Toast.makeText(context, )
        }

        private fun showSnackbar(context: Context, rootView: View?, errorInfo: ErrorInfo) {
//            if (rootView == null) {
//                creat
//            } else {
//
//            }
        }

    }
}